package com.atguigu.minio.controller;

import com.atguigu.minio.bean.JobInfo;
import com.atguigu.minio.service.JobInfoService;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("job")
public class JobInfoController {
    @Resource
    JobInfoService jobInfoService;
    @GetMapping("list")
    public List<JobInfo> list(JobInfo jobInfo){

        LambdaQueryWrapper<JobInfo> queryWrapper = Wrappers.lambdaQuery(JobInfo.class)
                .select(JobInfo::getJobSkills);
        if(!StringUtils.isEmpty(jobInfo.getSubCategory())){
            queryWrapper.eq(JobInfo::getSubCategory , jobInfo.getSubCategory());
        }
        if(!StringUtils.isEmpty(jobInfo.getProvince())){
            queryWrapper.eq(JobInfo::getProvince , jobInfo.getProvince());
        }
        if(!StringUtils.isEmpty(jobInfo.getJobEducation())){
            queryWrapper.eq(JobInfo::getJobEducation , jobInfo.getJobEducation());
        }
        return jobInfoService.list(queryWrapper);
    }
}
